﻿using B.S.BasicData.Api.Write.Application.Command.GridType;
using B.S.BasicData.Api.Write.Filters;
using B.S.BasicData.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Api.Write.Controllers
{
    /// <summary>
    /// 网格类型控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class GridTypeController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly ILogger<GridTypeController> logger;

        public GridTypeController(IMediator mediator, ILogger<GridTypeController> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }
        /// <summary>
        /// 新增网格类型
        /// </summary>
        /// <param name="request">网格类型请求命令参数</param>
        /// <returns>响应包装类</returns>
        [HttpPost]
        [AccessTokenFilter]
        public Task<ApiResult<int>> CreateGridtype(CreateGridtypeCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改网格类型
        /// </summary>
        /// <param name="request">网格类型请求命令参数</param>
        /// <returns>响应包装类</returns>
        [HttpPut]
        [AccessTokenFilter]
        public Task<ApiResult<int>> UpdateGridtype(UpdateGridtypeCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 删除网格类型
        /// </summary>
        /// <param name="request">网格类型请求命令参数</param>
        /// <returns>响应包装类</returns>
        [HttpPut]
        [Authorize]
        public   Task<ApiResult<int>> DelGridtype(DelGridtypeCommand request) {
            return mediator.Send(request);
        }
    }
}
